package control;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import view.ConfigPanel;
import view.EventTable;

import model.XMLWorker;

public class RemoveEvent implements ActionListener {
	
	private XMLWorker worker = null;
	private EventTable eventTable = null;
	private ConfigPanel configPanel = null;

	public RemoveEvent(XMLWorker worker, EventTable e) {
		super();
		this.worker = worker;
		eventTable = e;
		eventTable.setFilter(XMLWorker.ALLE, 0);
		eventTable.setFilter(XMLWorker.ALLE, 1);
		eventTable.setFilter(XMLWorker.ALLE, 2);
		eventTable.setFilter(XMLWorker.ALLE, 3);
	}

	@Override
	public void actionPerformed(ActionEvent arg0) {
		if(eventTable.getJTable().getSelectedColumn()!=-1) {
			int row = eventTable.getJTable().getSelectedRow();
			int column = 0;
			
//			eventTable.getJTable().getSelectionModel().clearSelection();
//			eventTable.getJTable().putClientProperty("termintateEditOnFocusLost", Boolean.TRUE);
//			eventTable.getJTable().clearSelection();
			worker.remove(Integer.valueOf(eventTable.getJTable().getValueAt(row, column).toString()));
			eventTable.setFilter(XMLWorker.ALLE, 0);
		}
	}

}
